
window.onload = function(){
	//blog页面视频控制
	var myVideo=document.getElementById("video");
	var videoPlay=document.getElementById("videoPlay");
	
	videoPlay.onclick = function(){
		if(myVideo.paused){
			myVideo.play(); 
			videoPlay.style.opacity = '0';
		}else{
			myVideo.pause(); 
		}
		videoPlay.onmouseover = function(){
			videoPlay.style.opacity = '1';
		}
		myVideo.onmouseover = function(){
			videoPlay.style.opacity = '1';
			videoPlay.style.transition = 'opacity 1s';
		}
		myVideo.onmouseout = function(){
			videoPlay.style.opacity = '0';
			videoPlay.style.transition = 'opacity 1s';
		}
	}
	var myMusic = document.getElementById('music');
	var musicBtn = document.getElementById('playBtn');
		musicBtn.onclick = function(){
			if(myMusic.paused){
				myMusic.play(); 
				$('#playBtn .play-btn1').hide();
				$('#playBtn .play-btn2').fadeIn('slow');
			}else{
				myMusic.pause(); 
				$('#playBtn .play-btn2').hide();
				$('#playBtn .play-btn1').fadeIn('slow');
			}
	}
	//blog页面的轮播图
	$(function() {
		var i = 0;
		var img = $('.blog-pics-item img');
		var spotDiv = $(".pics-spot div");
		//点击圆点实现图片切换
		for(var j = 0; j < 5; j++){
			document.getElementById('spot' + j).onclick = function(j){
				return function(){
					img.hide();
					img.eq(j).fadeIn("slow");
					i = j;
		    		spotDiv.removeClass("selectPicsSpot");
					$(this).addClass("selectPicsSpot");
				}
			}(j);
		}
		
		var id = setInterval(image, 3000);
		img.mouseover(function(){
			clearInterval(id);
		});
		
		img.mouseout(function(){
			id = setInterval(image,3000);
		});
		function image() {
			img.eq(i).css({
				"width": "0",
				"height": "0"
			});
			spotDiv.eq(i).removeClass("selectPicsSpot");
	
			i++;
			if(i == 5) {
				i = 0;
			}
	
			img.eq(i).fadeIn("slow");
			spotDiv.eq(i).addClass("selectPicsSpot");
	
			img.eq(i - 1).css({
				"width": "100%",
				"height": "100%"
			}).hide();
	
		}
		//动画控制
		var scrollTop = document.documentElement.scrollTop + document.body.scrollTop;
		var wordAnimated = $('.post-right-top .blog-post-word');
		var fristTitle = $('.blog-post-left-title .blog-title');
		var secondTitle = $('.poat-right-adjustColor .blog-title');
		
		$('.blog-post-left').mouseover(function(){
			fristTitle.addClass('animated bounceInLeft');
			 setTimeout(function(){
		        fristTitle.removeClass('animated bounceInLeft');
		    }, 1000);
		}); 
		
		$('.poat-right-adjustColor').mouseover(function(){
			secondTitle.addClass('animated bounceInRight');
			 setTimeout(function(){
		        secondTitle.removeClass('animated bounceInRight');
		    }, 1000);
		}); 
	
		$('.post-right-top').mouseover(function(){
			wordAnimated.addClass('animated swing');
			 setTimeout(function(){
		        wordAnimated.removeClass('animated swing');
		    }, 1000);
		}); 
		
	})
}
